package com.fr;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
*作者：furong
*日期：2017年5月3日
*时间：下午2:50:32
*/
public class SlowInterface {
    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader("F:\\_tmp_lbwa_result.txt");
        BufferedReader br = new BufferedReader(fr);
        String line = null;
        Map<String, Interface> map = new HashMap<>();
        while ((line = br.readLine()) != null) {
            String s[] = line.split("\t");
            int index = s[1].indexOf("?");
            String name = s[1];
            if (index > 0) {
                name = s[1].substring(0, index);
            }

            Interface i = map.get(name);
            if (i == null) {
                i = new Interface();
                i.name = name;
                i.count = 1;
                double cost = Double.parseDouble(s[0]);
                i.costTotal = cost;
                i.minCost = cost;
                i.maxCost = cost;
                map.put(name, i);
            } else {
                double cost = Double.parseDouble(s[0]);
                i.count++;
                i.costTotal += cost;
                if (cost > i.maxCost) {
                    i.maxCost = cost;
                }
                if (cost < i.minCost) {
                    i.minCost = cost;
                }
            }
        }
        for (Interface i : map.values()) {
            System.out.println(i.name + "\t" + i.maxCost + "\t" + i.minCost + "\t" + (i.costTotal / i.count) + "\t" + i.count);
        }
        br.close();
        fr.close();
    }

    static class Interface {
        String name;
        long count;
        double costTotal;
        double maxCost;
        double minCost;

    }
}
